<?php

/**
 * This is the model class for table "v_task_pelajaran_detail_semester".
 *
 * The followings are the available columns in table 'v_task_pelajaran_detail_semester':
 * @property integer $id
 * @property integer $task_pelajaran_id
 * @property integer $kelas_tahun_ajaran_id
 * @property string $task_date
 * @property string $name
 * @property string $pelajaran_name
 * @property string $notes
 * @property integer $is_active
 * @property string $department_id
 * @property integer $tahun_ajaran_id
 * @property string $semester_id
 * @property integer $pelajaran_id
 * @property string $task_name
 * @property string $task_group
 */
class VTaskPelajaranDetailSemester extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'v_task_pelajaran_detail_semester';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('task_pelajaran_id, kelas_tahun_ajaran_id, task_date, name, notes', 'required'),
			array('id, task_pelajaran_id, kelas_tahun_ajaran_id, is_active, tahun_ajaran_id, pelajaran_id', 'numerical', 'integerOnly'=>true),
			array('name', 'length', 'max'=>255),
			array('pelajaran_name, task_name, task_group', 'length', 'max'=>100),
			array('department_id', 'length', 'max'=>20),
			array('semester_id', 'length', 'max'=>11),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, task_pelajaran_id, kelas_tahun_ajaran_id, task_date, name, pelajaran_name, notes, is_active, department_id, tahun_ajaran_id, semester_id, pelajaran_id, task_name, task_group', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'task_pelajaran_id' => 'Task Pelajaran',
			'kelas_tahun_ajaran_id' => 'Kelas Tahun Ajaran',
			'task_date' => 'Task Date',
			'name' => 'Name',
			'pelajaran_name' => 'Pelajaran Name',
			'notes' => 'Notes',
			'is_active' => 'Is Active',
			'department_id' => 'Department',
			'tahun_ajaran_id' => 'Tahun Ajaran',
			'semester_id' => 'Semester',
			'pelajaran_id' => 'Pelajaran',
			'task_name' => 'Task Name',
			'task_group' => 'Task Group',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('task_pelajaran_id',$this->task_pelajaran_id);
		$criteria->compare('kelas_tahun_ajaran_id',$this->kelas_tahun_ajaran_id);
		$criteria->compare('task_date',$this->task_date,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('pelajaran_name',$this->pelajaran_name,true);
		$criteria->compare('notes',$this->notes,true);
		$criteria->compare('is_active',$this->is_active);
		$criteria->compare('department_id',$this->department_id,true);
		$criteria->compare('tahun_ajaran_id',$this->tahun_ajaran_id);
		$criteria->compare('semester_id',$this->semester_id,true);
		$criteria->compare('pelajaran_id',$this->pelajaran_id);
		$criteria->compare('task_name',$this->task_name,true);
		$criteria->compare('task_group',$this->task_group,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return VTaskPelajaranDetailSemester the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
